//
//  ABDiscoverSearchBar.swift
//  microblog
//
//  Created by 安波 on 15/11/5.
//  Copyright © 2015年 anbo. All rights reserved.
//

import UIKit
import FFAutoLayout

class ABDiscoverSearchBar: UIView {
    
    // MARK: - 构造函数
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = UIColor.redColor()
        
        prepareUI()
    }

    
    
    // MARK: - 准备UI
    /// 准备UI
    private func prepareUI() {
        // 添加子控件
        addSubview(textfield)
        addSubview(button)
        
        // 添加约束
        textfield.ff_AlignInner(ff_AlignType.CenterCenter, referView: self, size: CGSize(width: UIScreen.width() - 16, height: 38))
        button.ff_AlignInner(ff_AlignType.CenterRight, referView: textfield, size: CGSize(width: 40, height: 30))
        
    }

    // MARK: 懒加载
    /// textField
    private lazy var textfield: UITextField = {
       let textField = UITextField()
        
        textField.backgroundColor = UIColor.brownColor()
        textField.placeholder = "你好，......."
        
        return textField
    }()
    
    /// button
    private lazy var button: UIButton = {
       let button = UIButton()
        
        button.backgroundColor = UIColor.blueColor()
        button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
        button.setTitle("取消", forState: UIControlState.Normal)
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        
        button.addTarget(self, action: "buttonClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        return button
    }()
    
    func buttonClick(){
        print(__FUNCTION__)
    }

}
